package com.it.mapping;

import java.util.HashMap;
import java.util.Map;

public class MappingFactory {
    private static MappingFactory mappingFactory=null;
    private Map<String,EntityMapping> maps=new HashMap<>();
    public static final String ADMIN_MAPPING="adminmapping";
    public static final String SYS_USER_MAPPING="sys_usermapping";
    public static final String GUESTBOOK_MAPPING = "guestbookMapping";

    private MappingFactory() {
    }

    public static MappingFactory getInstance() {
        if (mappingFactory==null){
            mappingFactory= new MappingFactory();
            mappingFactory.maps.put(ADMIN_MAPPING,new AdminMapping());
            mappingFactory.maps.put(SYS_USER_MAPPING,new Sys_userMapping());
            mappingFactory.maps.put(GUESTBOOK_MAPPING, new GuestbookMapping());

        }
        return mappingFactory;
    }

    /**
     * 从工厂中获得实现类
     * @param key
     * @return
     */
    public EntityMapping getMap(String key){
        return maps.get(key);
    }

}
